extends TileMapLayer
class_name 导航层

var a_star: AStarGrid2D

var 网格数据集: Dictionary[Vector2i, 网格数据] = {}

func _ready():
	initAStarGrid2D()
	
	
func initAStarGrid2D():
	a_star = AStarGrid2D.new()
	a_star.region = get_used_rect()
	a_star.cell_size = tile_set.tile_size
	a_star.diagonal_mode = AStarGrid2D.DIAGONAL_MODE_NEVER
	
	a_star.update()
	
	# 设置不可行走的网格
	
	# 获取所有的瓦片
	var used_cells:=  get_used_cells()
	for cell in used_cells:
		网格数据集[cell] = 网格数据.new()
		if not get_cell_tile_data(cell).get_custom_data("可行走"):
			a_star.set_point_solid(cell)
			网格数据集[cell].可行走 = false
	
	
	
	
